package com.jyq.jsp.utils;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author Jiang Yongqiang
 */
public class ServletUtils {

    public static void setAttribute(HttpServletRequest request,String name,Object value){
        request.setAttribute(name,value);
    }
    public static void forward(HttpServletRequest request,HttpServletResponse response,String url){
        RequestDispatcher requestDispatcher = request.getRequestDispatcher(url);
        try {
            requestDispatcher.forward(request, response);
        } catch (ServletException | IOException e) {
            e.printStackTrace();
        }
    }

}
